<?php 
	include('function/connection.php');
	$cus_id = $cus_name = $cus_address = $cus_contact1 = $cus_contact2 = "";
	$action ="insert";
	$btn = "Save";
	
	if(isset($_POST['Submit'])){		
		$sql="INSERT INTO tbl_customers (cus_id,cus_name,cus_address,cus_contact1, cus_contact2)
		VALUES(
			'$_POST[txtCusID]',
			'$_POST[txtCusName]',
			'$_POST[txtCusAddress]',
			'$_POST[txtCusContact1]',
			'$_POST[txtCusContact2]')";
	
		mysql_query($sql);
		pageRedirect("index.php?page=sales&action=check_out&","$_POST[txtCusName]&one=, this customer added...!");
	}
	
	if(!isset($_GET['id'])){
		//max id
		$auto_id=maxOfAll("id","tbl_customers");
		$auto_id=$auto_id +1;
		$cus_id="C".$auto_id;
	}
	if(isset($_REQUEST['msgStatus'])){
		$cusForSale=$_REQUEST['msgStatus'];
	}
?>

<form action="index.php?page=customer_new_sale&action=customer_new_sale" method="post" class="form" name="form1" id="form1">
	<table class="bordered" width="770">
        <thead>
            <tr>
                <th>Please insert your customer information:<br /><span class="red">* require feild</span></th>
            </tr>
        </thead>
	</table>
    <table class="bordered" width="770">
		<tr>
			<td colspan="2">
            	<label><span class="red">*</span> Customer ID:</label>
				<input type="text" class="txtID" name="txtCusID" value="<?php echo $cus_id;?>" readonly="readonly" /> </td>           
            <td colspan="2">
            	<label><span class="red">*</span> Customer Name:</label>
            	<input type="text"  class="input req-min" minlength="1" style="width:200px; height:30px;" name="txtCusName" value="<?php echo $cus_name ?>" /> 
            </td>
		</tr>
        <tr>
        	<td colspan="4">
            	<label>Address:</label>
				<input type="text" class="txtCusAddress" name="txtCusAddress" value="<?php echo $cus_address ?>" />
           	</td>
		</tr>
        <tr>
			<td colspan="2">
            	<label>Contact1:</label>
				<input type="text"  class="input req-min" minlength="1" style="width:200px; height:30px;" name="txtCusContact1" value="<?php echo $cus_contact1 ?>" />
            </td>
            <td colspan="2">
            	<label>Contact2:</label>
            	<input type="text" class="txtCusContact2" name="txtCusContact2" value="<?php echo $cus_contact2 ?>" />
            </td>
		</tr>
		<tr>
			<td colspan="4"><input type="submit" class="btnSubmit" name="Submit" id="Submit" value="<?php echo $btn ?>" />&nbsp;  
            <input type="button" class="btnSubmit" name="btncancel" value="Cancel" onclick="redirect('index.php?page=sales&action=sales')" />
            </td>
		</tr>
	</table>
</form>